// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';


// 申明请求对象
const routeRequest = {
    // dict请求的基本url
    BASE_URL : confing.CZ_URL + "/route",
    /**
     * 保存字典信息
     * @param {*} route 
     * @param {*} callback 
     */
    save(route,callback){
        if(route){
            request.post(this.BASE_URL + "/save",route,callback);
        }
    },
    // 请求的API
    list(page = 1,limit = 10,route,callbcak){
        // url
        let url = this.BASE_URL + "/list?page=" + page + "&limit=" + limit;
        if(route){
            if(route.routeCode){
                url += "&routeCode=" + route.routeCode;
            }
            if(route.routeName){
                url += "&routeName=" + route.routeName;
            }
            if(route.routeStatus){
                url += "&routeStatus=" + route.routeStatus;
            }
        }
        // 发送请求
        request.get(url,callbcak);
    }
}

// 将routeRequest暴漏出去
export default routeRequest;